from django.db import models

# Create your models here.


class Book(models.Model):
    # 如果没有指定主键的话Django会自动新增一个自增id作为主键
    bookName = models.CharField(max_length=128, verbose_name='书名')
    createTime = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    def __unicode__(self):
        return self.bookName

    def __str__(self):
        return self.bookName

class CD(models.Model):
    avg_transaction = models.FloatField(verbose_name='平均交易额')
    transaction_cycle = models.FloatField(verbose_name='交易周期')
    longitude = models.FloatField(verbose_name='经度')
    latitude = models.FloatField(verbose_name='纬度')
    building_area = models.FloatField(verbose_name='建筑面积')
    total_floors = models.FloatField(verbose_name='总楼层数')
    listing_price = models.FloatField(verbose_name='挂牌价格')
    year_built = models.FloatField(verbose_name='建造年份')
    price_adjustment = models.FloatField(verbose_name='价格调整')
    viewing_count = models.FloatField(verbose_name='查看次数')
    followers_count = models.FloatField(verbose_name='关注人数')
    visitors_count = models.FloatField(verbose_name='访问人数')
    ladders = models.FloatField(verbose_name='楼梯数量')
    houses = models.FloatField(verbose_name='住宅数量')
    kitchens = models.FloatField(verbose_name='厨房数量')
    bedrooms = models.FloatField(verbose_name='卧室数量')
    living_rooms = models.FloatField(verbose_name='客厅数量')
    bathrooms = models.FloatField(verbose_name='卫生间数量')
    listing_year = models.FloatField(verbose_name='挂牌年份')
    listing_month = models.FloatField(verbose_name='挂牌月份')
    listing_day = models.FloatField(verbose_name='挂牌日期')
    #nei_price = models.FloatField(verbose_name='邻里价格')
    district_name = models.FloatField(verbose_name='区域名称')
    business_area = models.FloatField( verbose_name='商圈')
    community_name = models.FloatField(verbose_name='社区名称')
    apartment_type = models.FloatField(verbose_name='公寓类型')
    building_type = models.FloatField(verbose_name='建筑类型')
    house_orientation = models.FloatField(verbose_name='房屋朝向')
    renovation_status = models.FloatField(verbose_name='装修状态')
    building_structure = models.FloatField(verbose_name='建筑结构')
    heating_method = models.FloatField(verbose_name='供暖方式')
    elevator_available = models.FloatField(verbose_name='是否有电梯')
    transaction_rights = models.FloatField( verbose_name='交易权利')
    house_usage = models.FloatField(verbose_name='房屋用途')
    house_age = models.FloatField(verbose_name='房屋年龄')
    house_ownership = models.FloatField(verbose_name='房屋产权')

    def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)

    def __str__(self):
        return f"{self.community_name} - {self.listing_price}"